package cn.com.adcc.utils;

import java.io.File;
import java.util.ArrayList;

/**
 * Created by anzilu on 2015/10/9.
 */
public class Traversal {

    private static ArrayList filelist = new ArrayList();
    static long counter=0;
    public static void main(String[] args) {

        long a = System.currentTimeMillis();
        refreshFileList("c:\\");
        System.out.println(System.currentTimeMillis() - a);
        System.out.println(counter);
    }

    public static void refreshFileList(String strPath) {
        File dir = new File(strPath);
        File[] files = dir.listFiles();
        if (files == null)
            return;
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                refreshFileList(files[i].getAbsolutePath());
            } else {
                String strFileName = files[i].getAbsolutePath().toLowerCase();
                //System.out.println("---"+strFileName);
                counter++;
                filelist.add(files[i].getAbsolutePath());
            }
        }
    }
}
